package product

import (
	"gitee.com/xuxinzhi2206/corehub/database/mysql"
	"gorm.io/gorm"
)

//定单商品详情表

type OrderGoods struct {
	gorm.Model
	OrderId  int64  `gorm:"type:int(11);comment:订单id"`
	GoodId   int64  `gorm:"type:int(11);comment:商品id"`
	SkuID    int64  `gorm:"type:int(11);comment:skuId"`
	Price    string `gorm:"type:varchar(30);not null;comment:商品价格"`
	Quantity int64  `gorm:"type:int(11);comment:商品购买数量"`
}

// 订单商品列表详情
func (g *OrderGoods) OrderGoodsList(orderid int64) (ordergoods []*OrderGoods, err error) {
	return ordergoods, mysql.WithMysql(func(db *gorm.DB) error {
		err = db.Model(g).Where("order_id = ?", orderid).Find(&ordergoods).Error
		if err != nil {
			return err
		}
		return nil
	})
}
